package RobotBattleArena;

import java.util.Random;

/**
 * Created by Maxim on 14.02.2015.
 */
public class MediumRobot extends AbstractRobot{

    ////////// The variable declaration area \\\\\\\\\\
    private static int robotQty = 0; // quantity of robots.

    ////////// Class constructors \\\\\\\\\\

    // Default class constructor
    MediumRobot(){

        setRobotQty(getRobotQty() + 1);

        setName("BETA" + getRobotQty());

        Random generator = new Random();

        setHealth(50 + generator.nextInt(50));
        setPower(25 + generator.nextInt(25));
        setDefense(15 + generator.nextInt(15));
    }

    ////////// Class methods \\\\\\\\\\

    /*
    // When robot is attacked, he can evade and take no damage.
    // Returns:
    //  - true - evade was successful;
    //  - false - evasion failed.
    */
    public Boolean avoidAttack(int attackRate){

        int defenseRate; // displays the probability to evade attack

        Random generator = new Random();

        defenseRate = 25 + generator.nextInt(25);

        return defenseRate > attackRate;

    }

    ////////// Area of getters and setters \\\\\\\\\\

    // This method return amount of robots
    private int getRobotQty() {
        return robotQty;
    }

    // This method set amount of robots
    private void setRobotQty(int qty){
        robotQty = qty;
    }

    // This method return robot name
    public String getName() {
        return name;
    }
}
